package com.yijiajiao.finance.scheduler;

import com.yijiajiao.finance.service.BatchPayService;
import com.yijiajiao.finance.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务
 *
 * @AUTHOR zhaoming@eduspace
 * @CREATE 2017-08-09-15:36
 */
@Component
public class Scheduler {

    private final Logger log = LoggerFactory.getLogger(Scheduler.class);

    private int cout = 0;

    @Autowired
    private BatchPayService batchPayService;

    @Scheduled(cron = "0 30 0 1 * ?")
    public void settleAccountsForMonth(){

        log.info("今天是本月第一天："+ DateUtil.getNowTime()+",进行教师上月收入结算");
        int count = batchPayService.getAndSaveSalary();
        log.info("结算完成，人数="+count);

    }

}
